
<html ng-app="app">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="../../build/common/base.css" rel="stylesheet">
	<script type="text/javascript" src="../../build/common/base.js"></script>
	<script type="text/javascript" src="../../build/common/ngEdit.js"></script>
	<script type="text/javascript" src="../../assets/js/platform/bus/businessObject/businessObjectEditController.js"></script>
	<script type="text/javascript" src="../../assets/js/platform/bus/businessObject/editAndDialogCommon.js"></script>
	<script type="text/javascript">

	</script>
</head>
<body ng-controller="ctrl" ng-init="init()" class="panel success">
<div class="ibox-title">
	<a class="btn btn-primary fa-save" href="javascript:void(0)" ng-model="data" ab-save="/bus/businessObject/save">保存</a>
	<a href="javascript:void(0)" class="btn btn-primary fa-reply" onclick="javascript:$.Dialog.close(window);">取消</a>
	<a href="javaScript:void(0)" openDialog='业务对象总体布置' url='./businessObjectOverallArrangement.html?boCode={{data.key}}' ng-show="data.id" class="btn btn-primary fa-edit">配置控件布局</a>
</div>
<form name="form" ab-load="/bus/businessObject/getObject?id={id}" ng-model="data" fastjson>
	<table class="form-table form-table-2">
		<tr>
			<th>分类</th>
			<td>
				<span ab-combox="data.groupId" value-name="data.groupName" tree-key="ywdxfl" ng-model="data.groupName" ab-validate="{required:true}"></span>
			</td>
			<th>持久化方式</th>
			<td>
				<select class="form-control" style="width: 150px;" ng-model="data.persistenceType" ng-change="data.perTypeConfig=null" ng-options="v.key as v.desc for (k,v) in BusinessObjectPersistenceType">
				</select>
			</td>
		</tr>
		<tr>
			<th>名字</th>
			<td>
				<input ng-model="data.name" ab-validate="{required:true,maxlength:30}" class="form-control" />
			</td>
			<th>对象名</th>
			<td>
				<input ng-model="data.key" ab-validate="{required:true,varirule:true}" class="form-control" ab-pinyin="data.name" />
			</td>
		</tr>
		<tr>
			<th>描述</th>
			<td>
				<textarea ng-model="data.desc" class="form-control w100" ab-validate="{maxlength:80}"></textarea>
			</td>
			<th>主业务表</th>
			<td>
				{{data.relation.tableComment}}({{data.relation.tableKey}})
				<a class="btn  btn-primary fa-search" href="javascript:void(0)" ng-click="selectMainTable()">选择</a>
			</td>
		</tr>
	</table>
	<br />
	<div class="btn-group toolbar">
		<a class="btn btn-primary btn-outline fa-add " ng-click="addSubTable(data.relation.children)">
			<span>添加子业务实体</span>
		</a>
	</div>
	<table ng-show="data.relation" class="table table-hover table-bordered form-table form-table-list" cellspacing="0">
		<tr class="th-center">
			<th width="10%" style="width: 150px;">类型</th>
			<th width="10%">名称</th>
			<th width="10%">实体名</th>
			<th width="60%" style="width: 440px;">外键</th>
			<th width="10%">操作</th>
		</tr>
		<tr ng-repeat="child in data.relation.children">
			<td>
				<select class="form-control wd120" ab-validate="{required:true}" ng-model="child.type" ng-options="v.key as v.desc for (k,v) in BusTableRelType">
				</select>
			</td>
			<td>{{child.tableComment}}</td>
			<td>{{child.tableKey}}</td>
			<td class="nowrap">
				<div ng-repeat="fk in child.fks" class="w100 clear mt5">
					<select ng-model="fk.from" ab-validate="{required:true}" ng-options="m.key as m.comment for m in tableMap[child.tableKey].columns" class="form-control wd100 fl">
						<option value="">请选择</option>
					</select>
					<select ng-model="fk.type" ng-options="v.key as v.desc for (k,v) in BusTableRelFkType"  class="form-control wd220 fl">
					</select>
					<input ng-if="fk.type=='fixedValue'" type="text" ng-model="fk.value"  class="form-control wd120 fl"/>
					<span ng-if="fk.type=='parentField'||fk.type=='childField'">
							<select ng-model="fk.value" ab-validate="{required:true}" ng-options="m.key as m.comment for m in tableMap[data.relation.tableKey].columns"  class="form-control wd100 fl">
								<option value="">请选择</option>
							</select>
						</span>
					<a href="javaScript:void(0)" class="btn btn-xs btn-default fa-add fl mt3 ml5" ng-click="addFk(child.fks)"></a>
					<a ng-show="child.fks.length>1" href="javaScript:void(0)" class="btn btn-xs btn-default fa-times fl mt3 ml5" ng-click="child.fks.remove(fk)"></a>
				</div>
			</td>
			<td>
				<a href="javaScript:void(0)" ng-click="ArrayTool.del($index,data.relation.children)" class="btn btn-outline btn-primary fa  fa-trash"></a>
				<a href="javaScript:void(0)" ng-click="openChildrenDialog(child)" class="btn btn-sm btn-primary btn-outline fa-edit">配置子表</a>
			</td>
		</tr>
	</table>
</form>
</body>
</html>